const axios = require('axios');
const cozeToken = require('./cozeToken');

// 执行工作流
async function workflowRun(workflow_id, parameters) {
  try {
    const headers = await cozeToken.getAuthHeaders();
    const response = await axios.post(
      'https://api.coze.cn/v1/workflow/run',
      {
        workflow_id: workflow_id,
        parameters: parameters
      },
      {
        headers: headers
      }
    );
    return response.data;
  } catch (error) {
    console.error('执行工作流失败:', error);
    throw error;
  }
}

module.exports = {
  workflowRun
};